package com.starblink.android.basic.ext

import android.app.Activity
import android.app.Dialog
import androidx.fragment.app.Fragment
import com.blankj.utilcode.util.PermissionUtils
import com.starblink.basic.style.R
import com.starblink.android.basic.widget.ConfirmDialog

/**
 *  Create by yuanl at 2023/4/28
 **/

fun Activity.showCameraAccessDialog() {
    createCameraAccessDialog().show()
}

fun Activity.createCameraAccessDialog(): Dialog {
    return ConfirmDialog.Builder(this)
        .setMessage(string(R.string.access_camera_tip))
        .setTitle(string(R.string.access_camera))
        .setSureButton(string(R.string.access_camera_ok)) { dialog, which ->
            dialog.dismiss()
            PermissionUtils.launchAppDetailsSettings()
        }.create()
}


fun Activity.createAlbumAccessDialog(): Dialog {
    return ConfirmDialog.Builder(this)
        .setMessage(string(R.string.access_album_tip))
        .setTitle(string(R.string.access_album))
        .setSureButton(string(R.string.access_camera_ok)) { dialog, which ->
            dialog.dismiss()
            PermissionUtils.launchAppDetailsSettings()
        }.create()
}


fun Fragment.showCameraAccessDialog() {
    context?.let {
        ConfirmDialog.Builder(it)
            .setMessage(string(R.string.access_camera_tip))
            .setTitle(string(R.string.access_camera))
            .setSureButton(string(R.string.access_camera_ok)) { dialog, which ->
                dialog.dismiss()
                PermissionUtils.launchAppDetailsSettings()
            }.create().show()
    }

}